/**
 * 
 */
package org.mspring.codegen.engine.utils;

import java.io.IOException;
import java.util.Locale;

import org.mspring.codegen.template.TemplatePath;

import freemarker.template.Configuration;
import freemarker.template.Template;

/**
 * 模板处理通用类
 * 
 * @author Gao Youbo
 * @since 2013-6-18
 */
public class TemplateUtils {
    /**
     * 默认生成文件存放路径
     */
    public static final String DEFAULT_FOLDER = "D:/codegen";

    public static Template getTemplate(String name) {
        Configuration cfg = new Configuration();
        cfg.setClassForTemplateLoading(TemplatePath.class, "");
        cfg.setEncoding(Locale.getDefault(), "UTF-8");

        Template template = null;
        try {
            template = cfg.getTemplate(name, "UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return template;
    }

}
